package com.mdinfo.system.mapper

import com.baomidou.mybatisplus.mapper.BaseMapper
import com.mdinfo.system.bean.SysMember
import org.apache.ibatis.annotations.Param
import org.apache.ibatis.annotations.Select

/**
 * Created by Administrator on 2017/12/28.
 */
interface SysMemberMapper2 : BaseMapper<SysMember>{

    /**
     * 列表条件分页查询
     */
    @Select("""<script>
select * from sys_member t where 1=1
    <if test="deptId!=null">
        and t.deptId = #{deptId}
    </if>
    <if test="key!=null">
        <![CDATA[
        and t.username like CONCAT('%',#{key},'%')
        ]]>
    </if>
    <if test="deptList!=null and deptList.size>0">
        and t.deptId in
        <foreach collection="deptList" separator="," open="(" close=")" item="dept_id">
            #{dept_id}
        </foreach>
    </if>
order by t.lastLoginTime DESC
limit #{start},#{num}
</script>""")
    fun listQuery(@Param("start") start: Int?,
                  @Param("num") num: Int?,
                  @Param("deptId") deptId: Int?,
                  @Param("key") key: String,
                  @Param("deptList") deptList: List<Int>): List<SysMember>
}